import { request } from '../utils'
import { Toast } from "vant"

/*
  立即购买方式提交订单
*/
const postSubmitOrder = (requestData, cb) => {
  request({
    method: "POST",
    url: "api/order/PostSubmitOrder",
    data: requestData
  }).then(res => {
    if (res.data.Success) {
      cb && cb(res.data.Data.OrderIds[0])
    } else {
      console.log("订单提交失败...")
      Toast(res.data.Msg)
    }
  })
}

/*
  购物车方式提交订单
*/
const postSubmitOrderByCart = (requestData, cb) => {
  request({
    method: "POST",
    url: "api/order/PostSubmitOrderByCart",
    data: requestData
  }).then(res => {
    if (res.data.Success) {
      cb && cb(res.data.Data.OrderIds[0])
    } else {
      console.log("订单提交失败...")
      Toast(res.data.Msg)
    }
  })
}



export { postSubmitOrder, postSubmitOrderByCart }